<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 20064
  Date: 2020/2/16
  Time: 10:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户账单</title>

    <!-- 图标 -->
    <link rel="icon" type="image/png" sizes="144x144" href="../images/airplane.png"/>
    <link rel="apple-touch-icon" type="image/png" sizes="144x144" href="../images/airplane.png"/>

    <!-- 其他 -->
    <link rel="stylesheet" href="../js/bootstrap-4.4.1-dist/css/bootstrap.min.css">
    <style type="text/css">
        .row {
        }

        .back {
            margin-right: 50px;
        }

        table button {
            margin-top: -7px;
        }
    </style>

    <!-- js -->
    <script type="text/javascript" src="../js/jquery-3.4.1/jquery-3.4.1.js"></script>
</head>
<body>
<div class="container">
    <div class="row">
        <div class="w-100">
            <button type="button" class="btn btn-secondary float-right back" onclick="goBack()">返回主页</button>
        </div>
    </div>
    <div class="row">&nbsp;</div>
    <div class="row">
        <div class="card w-100 shadow">
            <div class="card-header">
                <h2>账单</h2>
            </div>
            <div class="card-body">
                <table class="table table-hover text-center">
                    <thead>
                    <tr>
                        <th>账单ID</th>
                        <th>航班ID</th>
                        <th>出发地</th>
                        <th>&nbsp;</th>
                        <th>目的地</th>
                        <th>出发时间</th>
                        <th>到达时间</th>
                        <th>航班状态</th>
                        <th>客户账号</th>
                        <th>&nbsp;</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:if test="${expenseList == null || expenseList.size() == 0}">
                        <tr>
                            <td colspan="9">暂没有订单</td>
                        </tr>
                    </c:if>
                    <c:forEach items="${expenseList}" var="expense">
                        <tr>
                            <td>${expense.expenseId}</td>
                            <td>${expense.expenseFlight.flightId}</td>
                            <td>${expense.expenseFlight.flightStartArea.cityName}</td>
                            <td>-></td>
                            <td>${expense.expenseFlight.flightEndArea.cityName}</td>
                            <td>${expense.expenseFlight.flightStartTime}</td>
                            <td>${expense.expenseFlight.flightEndTime}</td>
                            <td>${expense.expenseFlight.flightStatus.statusTypeName}</td>
                            <td>${expense.expenseUSer.userAccount}</td>
                            <td>
                                <c:choose>
                                    <c:when test="${expense.expenseFlight.flightStatus.statusTypeId == 1}">
                                        <button class="btn btn-info" type="button"
                                                onclick="changeFlight(${expense.expenseId})">
                                            改签
                                        </button>
                                        <button class="btn btn-warning text-white" type="button"
                                                onclick="backTicket(${expense.expenseId})">
                                            退票
                                        </button>
                                    </c:when>
                                    <c:otherwise>
                                        <button class="btn btn-info" type="button" disabled="disabled">改签</button>
                                        <button class="btn btn-warning text-white" type="button" disabled="disabled">退票
                                        </button>
                                    </c:otherwise>
                                </c:choose>

                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>

            </div>
        </div>
    </div>
</div>


</body>
<script type="text/javascript" src="../js/bootstrap-4.4.1-dist/js/bootstrap.min.js"></script>
<script type="text/javascript">
    function goBack() {
        location.href = "getHotCity.do";
    }

    function backTicket(id) {
        var v = confirm("真的要退票吗？");
        if (v) {
            location.href = "backTicket.do?expenseId=" + id;
        }
    }

    function changeFlight(id) {
        location.href = "changeFlight.do?expenseId=" + id;
    }
</script>
</html>
